package com.ruoyi.web.controller.student;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.student.domain.StudentClassCourse;
import com.ruoyi.student.service.IStudentClassCourseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班级课程Controller
 * 
 * @author ruoyi
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/student/studentClassCourse")
public class StudentClassCourseController extends BaseController
{
    @Autowired
    private IStudentClassCourseService studentClassCourseService;

    /**
     * 查询班级课程列表
     */
    @PreAuthorize("@ss.hasPermi('student:studentClassCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentClassCourse studentClassCourse)
    {
        startPage();
        List<StudentClassCourse> list = studentClassCourseService.selectStudentClassCourseList(studentClassCourse);
        return getDataTable(list);
    }

    /**
     * 导出班级课程列表
     */
    @PreAuthorize("@ss.hasPermi('student:studentClassCourse:export')")
    @Log(title = "班级课程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentClassCourse studentClassCourse)
    {
        List<StudentClassCourse> list = studentClassCourseService.selectStudentClassCourseList(studentClassCourse);
        ExcelUtil<StudentClassCourse> util = new ExcelUtil<StudentClassCourse>(StudentClassCourse.class);
        util.exportExcel(response, list, "班级课程数据");
    }

    /**
     * 获取班级课程详细信息
     */
    @PreAuthorize("@ss.hasPermi('student:studentClassCourse:query')")
    @GetMapping(value = "/{classId}")
    public AjaxResult getInfo(@PathVariable("classId") String classId)
    {
        return success(studentClassCourseService.selectStudentClassCourseByClassId(classId));
    }

    /**
     * 新增班级课程
     */
    @PreAuthorize("@ss.hasPermi('student:studentClassCourse:add')")
    @Log(title = "班级课程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentClassCourse studentClassCourse)
    {
        return toAjax(studentClassCourseService.insertStudentClassCourse(studentClassCourse));
    }

    /**
     * 修改班级课程
     */
    @PreAuthorize("@ss.hasPermi('student:studentClassCourse:edit')")
    @Log(title = "班级课程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentClassCourse studentClassCourse)
    {
        return toAjax(studentClassCourseService.updateStudentClassCourse(studentClassCourse));
    }

    /**
     * 删除班级课程
     */
    @PreAuthorize("@ss.hasPermi('student:studentClassCourse:remove')")
    @Log(title = "班级课程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classIds}")
    public AjaxResult remove(@PathVariable String[] classIds)
    {
        return toAjax(studentClassCourseService.deleteStudentClassCourseByClassIds(classIds));
    }
}
